package object;

/**
 * 抽象类不能被实例化
 * 抽象类中不一定有抽象方法，有抽象方法的类一定是抽象类
 * 可以有构造方法
 */


abstract class FatherObject {

	private String name;
	private int age;

	public FatherObject() {
	}

	public FatherObject(String name, int age) {
		this.name = name;
		this.age = age;
	}

	/**
	 * 获取
	 *
	 * @return name
	 */
	public String getName() {
		return name;
	}

	/**
	 * 设置
	 *
	 * @param name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * 获取
	 *
	 * @return age
	 */
	public int getAge() {
		return age;
	}

	/**
	 * 设置
	 *
	 * @param age
	 */
	public void setAge(int age) {
		this.age = age;
	}

	public String toString() {
		return "FatherObject{name = " + name + ", age = " + age + "}";
	}

	public void drink() {
		System.out.println("I am drinking");
	}

	public abstract void eat();

}

class ChildObject extends FatherObject {

	public ChildObject() {
	}

	public ChildObject(String name, int age) {
		super(name, age);
	}

	@Override
	public void eat() {
		System.out.println("child am eating");
	}

	public String toString() {
		return super.toString();
	}
}


public class AbstractObject {
	public static void main(String[] args) {
//		ChildObject c1 = new ChildObject("jason", 22);
//		System.out.println(c1.toString());

		FatherObject c1 = new ChildObject();


	}
}
